extends Area2D
class_name HurtBoxComponent




@export var health_component: HealthComponent

func _ready() -> void:
	area_entered.connect(on_area_entered)

func on_area_entered(area:Area2D) -> void:
	if not area is HitBoxComponent: return
	var hitbox = area as HitBoxComponent

	
	if health_component != null:
		health_component.damage(hitbox.damage)
		
		# 发射命中信号（用于能力组件监听）
		if hitbox.owner_node.has_signal("hit_target"):
			hitbox.owner_node.hit_target.emit(owner)
	else:
		owner.queue_free()
